package com.origin.learn.dbpool;

import java.sql.Connection;

/**
 * @Description: 自定义连接的连接池，可以直接继承{@link CommonConnectionPool}，然后实现{@code createConnection}即可
 * @Date: 2020/2/29
 * @Time: 14:40
 * @Created by:   dingtao
 * @Modified by:
 * @Modified at:
 */
public class StupidUselessConnectionPool extends CommonConnectionPool {

    /**
     * 自定义连接相关的一些参数
     */
    private String param1;
    private String param2;
    private String param3;

    public StupidUselessConnectionPool(int initSize, int coreSize, int maxSize, long checkIntervalTime,
                                       String param1, String param2, String param3){
        super(initSize, coreSize, maxSize, checkIntervalTime);

        this.param1 = param1;
        this.param2 = param2;
        this.param3 = param3;
        for (int i = 0; i < initSize; i++) {
            getPool().offer(createConnection());
        }
    }

    @Override
    public Connection createConnection() {
        Connection connection = new StupidUselessConnection(param1, param2, param3);
        return connection;
    }
}
